#ifndef KANGSHIFUQTMATCHING_HTTPCLIENTSINGLETON_H
#define KANGSHIFUQTMATCHING_HTTPCLIENTSINGLETON_H
#include <string>
#include <curl/curl.h>
#include <iostream>
#include <mutex>

class HttpClientSingleton {
public:
    // 获取全局唯一实例
    static HttpClientSingleton& getInstance();

    // 禁止拷贝和赋值
    HttpClientSingleton(const HttpClientSingleton&) = delete;
    HttpClientSingleton& operator=(const HttpClientSingleton&) = delete;

    // 发送 POST JSON 请求
    std::string postJson(const std::string& url, const std::string& jsonData);

private:
    HttpClientSingleton();  // 私有构造
    ~HttpClientSingleton(); // 私有析构

    static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp);

private:
    CURL* curl;
    static std::mutex mtx;
};
#endif //KANGSHIFUQTMATCHING_HTTPCLIENTSINGLETON_H
